package com.example.administrator.himalaya.criticallies;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.administrator.himalaya.R;
import com.example.administrator.himalaya.adapter.ProgramAdapter;
import com.example.administrator.himalaya.callback.ProgramService;
import com.example.administrator.himalaya.entity.categoryentity.ProgramEntity;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * A simple {@link Fragment} subclass.
 * 节目
 */
public class ProgramFragment extends Fragment {


    private RecyclerView recycler;
    private ProgramAdapter adapter ;
    private TextView introtv;

    public ProgramFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_program, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
//        recycler = (RecyclerView) view.findViewById(R.id.recycler_progream1);
        introtv = (TextView) view.findViewById(R.id.tv_program_item2);
        Intent intent =getActivity().getIntent();
        String id = intent.getStringExtra("id");
        ProgramService service = new Retrofit.Builder()
                .baseUrl("http://mobile.ximalaya.com/mobile/v1/album/")
                .addConverterFactory(GsonConverterFactory.create())
                .build()
                .create(ProgramService.class);
        service.program(3523862).enqueue(new Callback<ProgramEntity>() {
            @Override
            public void onResponse(Call<ProgramEntity> call, Response<ProgramEntity> response) {
                ProgramEntity body = response.body();
//                Log.d("1234",body.getData().getDetails().getIntro());
//                String intro = body.getData().getDetails().getIntro();
//                introtv.setText(intro);

            }

            @Override
            public void onFailure(Call<ProgramEntity> call, Throwable t) {

            }
        });

    }


}
